#include<iostream>
using namespace std;
class Solution {
public:
    int multiply(int A, int B) {
        if (A < B)
            swap(A, B);
        if (B == 0) return 0;
        if (B == 1) return A;
        return multiply(A << 1, B >> 1) + ((B & 1) == 1 ? A : 0);
    }
};
